// 高级特性
// 参数属性
// get/set 方法
// 抽象类
// 类可以用于定义构造函数的类型，实例的类型，当作接口使用

// 类的基本定义
class Animal {
	protected readonly name: string
	constructor(name: string) {
		this.name = name
	}
	run() {
		return `${this.name} is running`
	}
}
const snake = new Animal('dog')
snake.run()

// 继承
class Dog extends Animal {
	bark() {
		return `${this.name} is barking`
	}
}

const huangDog = new Dog('huang')
huangDog.run()

// 多态
class Cat extends Animal {
	constructor(name: string) {
		super(name)
	}
	run() {
		return 'Meow, ' + super.run()
	}
}
const mao = new Cat('maomao')
mao.run()

// 继承类接口
interface ClockInterface {
	currentTime: number
	alert(): void
}

interface ClockStatic {
	new (h: number, m: number): void
	time: number
}

interface GameInterface {
	play(): void
}

const Clock: ClockStatic = class Clock implements ClockInterface {
	static time = 12
	currentTime = 123
	alert() {
		console.log('alert')
	}
}

class Cellphone implements ClockInterface, GameInterface {
	currentTime = 123
	alert() {
		console.log('alert')
	}
	play() {
		console.log('play')
	}
}

export {}
